<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Web SQL</title>
</head>
<body>
<script type="text/javascript">
    var db = openDatabase('mydb', '1.0', 'Test DB', 2 * 1024 * 1024);

    var a = "aaa";
    var b = "bbb";
    db.transaction(function (tx) {
        // tx.executeSql('CREATE TABLE IF NOT EXISTS LOGS (id UNIQUE, log)');
        // tx.executeSql('INSERT INTO LOGS (id, log) VALUES (1, ?)', [a]);
        // tx.executeSql('INSERT INTO LOGS (id, log) VALUES (2, ?)', [b]);
        // tx.executeSql('INSERT INTO LOGS (id, log) VALUES (3, ?)', [a]);
        // tx.executeSql('INSERT INTO LOGS (id, log) VALUES (4, ?)', [a]);
        // tx.executeSql('INSERT INTO LOGS (id, log) VALUES (5, ?)', [a]);
        // tx.executeSql('DELETE FROM LOGS  WHERE id=1');
        // tx.executeSql('UPDATE LOGS SET log=\'ccc\' WHERE id=2');
    });


    db.transaction(function (tx) {
        tx.executeSql('SELECT * FROM LOGS', [], function (tx, results) {
            var len = results.rows.length, i;
            msg = "<p>查询记录条数: " + len + "</p>";
            console.log(msg);
            for (i = 0; i < len; i++) {
                // alert(results.rows.item(i).log);
            }
        }, null);
    });
</script>
</body>
</html>